package my.study.org.springframework.aop.examples.example1;


import java.lang.reflect.Method;

import org.springframework.aop.AfterReturningAdvice;
import org.springframework.aop.MethodBeforeAdvice;
import org.springframework.aop.ThrowsAdvice;

/*
 * 
 */
public class AudienceAdvice implements MethodBeforeAdvice, AfterReturningAdvice, ThrowsAdvice {

	private Audience audience;
	public void afterReturning(Object returnValue, Method method,
			Object[] args, Object target) throws Throwable {
		audience.applaud();		
	}

	public void before(Method method, Object[] args, Object target)
			throws Throwable {
		System.out.println("AudienceAdvice.before()");
		this.audience.takeSeats();
		this.audience.turnOffCellPhones();
	}

	public void afterThrowing(Throwable throwAble) {
		this.audience.demandRefund();
	}

	public Audience getAudience() {
		return audience;
	}

	public void setAudience(Audience audience) {
		this.audience = audience;
	}
	
	
}
